﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KPIS.GERP.GFMS.MODEL;
using KPIS.GERP.GFMS.IBLL;
using KPIS.GERP.GFMS.IDAL;
using KPIS.GERP.GFMS.DALFactory;

// test only
using KPIS.GERP.GFMS.DAL;

namespace KPIS.GERP.GFMS.BLL
{
    public class B_FIM_PaymentCheques : IBLL_FIM_PaymentCheques
    {
        Common common = new Common();
        private static readonly IDAL_FIM_PaymentCheques dal = DataAccess.Create_FIM_PaymentCheques();
        //D_FIM_MAS_Receives r = new D_FIM_MAS_Receives();

        public B_FIM_PaymentCheques()
        {

        }

        public IList<M_FIM_PaymentCheques> GetFull(string pay_seq, string cheque_seq)
        {
            Nullable<int> npay_seq = common.ConvertNullInt(pay_seq);
            Nullable<int> ncheque_seq = common.ConvertNullInt(cheque_seq);
            return dal.GetFull(npay_seq, ncheque_seq);
        }

        public IList<M_FIM_PaymentCheques> GetPaymentCheques(string pay_seq)
        {
            Nullable<int> npay_seq = common.ConvertNullInt(pay_seq);
            return dal.GetPaymentCheques(npay_seq);
        }

        //public IList<M_FIM_PaymentCheques> GetList(string bgm_source_seq
        //    , string bgm_year, string work_area_seq, string event_seq)
        //{
        //    Nullable<int> nbgm_source_seq = common.ConvertNullInt(bgm_source_seq);
        //    Nullable<int> nbgm_year = common.ConvertNullInt(bgm_year);
        //    Nullable<int> nwork_area_seq = common.ConvertNullInt(work_area_seq);
        //    Nullable<int> nevent_seq = common.ConvertNullInt(event_seq);
        //    return dal.GetList(nbgm_source_seq, nbgm_year, nwork_area_seq, nevent_seq);
        //}

        public M_FIM_PaymentCheques GetInfo(string seq)
        {
            int nSeq;
 
            if (seq == null)
                return null;

            if (common.IsNumeric(seq))
            {
                nSeq = int.Parse(seq);
                return dal.GetInfo(nSeq);
            }
            else
            {
                return null;
            }
        }

        public void Insert(M_FIM_PaymentCheques info)
        {
            try
            {
                dal.Insert(info);
            }
            catch
            {
                throw;
            }
        }

        public void Update(M_FIM_PaymentCheques info)
        {
            try
            {
                dal.Update(info);
            }
            catch
            {
                throw;
            }
        }

        public void Delete(M_FIM_PaymentCheques info)
        {
            try
            {
                dal.Delete(info);
            }
            catch
            {
                throw;
            }
        }

        public string SumMoney(string strCheque)
        {
            return dal.SumMoney(strCheque);
        }
    }
}
